package contol;

public class IfControl {

    public static void main(String[] args) {
        //ifesle(10,5);
        //ifesle(1,5);
        ifesle(5, 5);
    }

    /**
     * 只要进入if(else if)语句判定为true就会执行对应语句，
     * 执行完成下面的else if就不会执行
     *
     * @param testval
     * @param target
     * @return
     */
    public static int ifesle(int testval, int target) {
        int result = 0;
        if (test("testval > target") && testval > target) {
            result = +1;
        }
        else if (test("testval < target") && testval < target) {
            result = -1;
        }
        else if (test("else")) {
            result = 0;
        }
        else {
            throw new RuntimeException("之外的条件");
        }
        return result;
    }

    private static boolean test(String msg) {
        System.out.println(msg);
        return true;
    }
}
